package com.ssuu.ssuusnow.model.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel(value = "ResultVo对象", description = "统一返回")
public class ResultVo {
    @ApiModelProperty("状态码")
    private int code;

    @ApiModelProperty("返回信息")
    private String msg;

    @ApiModelProperty("返回信息")
    private Object data;

    public ResultVo(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultVo(Object data) {
        this.code = ResultCode.SUCCESS.getCode();
        this.msg = ResultCode.SUCCESS.getMsg();
        this.data = data;
    }
    public static ResultVo ResultVoSuccess(Object data) {
        return new ResultVo(ResultCode.SUCCESS,data);
    }
    public static ResultVo ResultVoFail(Object data) {
        return new ResultVo(ResultCode.FAILED,data);
    }
    public static ResultVo ResultVoFAILEDNOT(Object data) {
        return new ResultVo(ResultCode.FAILEDNOT,data);
    }
    public static ResultVo ResultVoValidate(Object data) {
        return new ResultVo(ResultCode.VALIDATE_ERROR,data);
    }
    public static ResultVo ResultERROR(Object data) {
        return new ResultVo(ResultCode.ERROR,data);
    }

    public ResultVo(StatusCode statusCode, Object data) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
        this.data = data;
    }

    public ResultVo(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
        this.data = null;
    }
}
